﻿using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace K9Nano.Configuration
{
    /// <summary>
    /// This interface is used to get/set settings from/to a data source (database).
    /// </summary>
    public interface ISettingStore
    {
        /// <summary>
        /// Gets a setting or null.
        /// </summary>
        /// <param name="tenantId">TenantId or null</param>
        /// <param name="userId">UserId or null</param>
        /// <param name="name">Name of the setting</param>
        /// <returns>Setting object</returns>
        ValueTask<SettingInfo> GetSettingOrNullAsync(Guid? tenantId, Guid? userId, string name, CancellationToken cancellation = default);

        /// <summary>
        /// Deletes a setting.
        /// </summary>
        /// <param name="setting">Setting to be deleted</param>
        ValueTask DeleteAsync(SettingInfo setting, CancellationToken cancellation = default);

        /// <summary>
        /// Update a setting.
        /// </summary>
        /// <param name="setting">Setting to add</param>
        ValueTask CreateOrUpdateAsync(SettingInfo setting, CancellationToken cancellation = default);

        /// <summary>
        /// Gets a list of setting.
        /// </summary>
        /// <param name="tenantId">TenantId or null</param>
        /// <param name="userId">UserId or null</param>
        /// <returns>List of settings</returns>
        ValueTask<IReadOnlyList<SettingInfo>> GetAllListAsync(Guid? tenantId, Guid? userId, CancellationToken cancellation = default);
    }
}